package com.hxy.tlias.mapper;

import com.hxy.tlias.pojo.Emp;
import com.hxy.tlias.pojo.EmpExpr;
import com.hxy.tlias.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

    /**
     * 列表查询
     * @return
     */
    //原无条件分页查询sql@Select("select e.*,d.name deptName from tlias.emp e left join tlias.dept d on e.dept_id = d.id")
    List<Emp> list(EmpQueryParam param);

    //新增员工
    //@Options(useGeneratedKeys = true,keyProperty = "id")  //获取主键的值并赋id属性
    //@Insert("insert into tlias.emp values(null,#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);

    //批量删除
    void deleteBatch(List<Integer> ids);

    ////员工修改-回显
    Emp getById(Integer id);

    @Select("select * from emp where id = #{id}")
    Emp getById2(Integer id);

    //员工修改
    void update(Emp emp);

    /**
     * 统计各职位员工人数
     * @return
     */
    @MapKey("pos")  //可以不加，不影响业务...
    List<Map> countByJob();

    @MapKey("name")
    List<Map> countByGender();

    /**
     * 根据部门id统计员工人数
     * @param deptId
     * @return
     */
    @Select("select count(*) from emp where dept_id = #{deptId}")
    Integer countByDeptId(Integer deptId);


    Emp selectUsernameAndPassword(Emp emp);
}
